<template>
  <div class="list">
    <h2>猜你喜欢</h2>
    <ul class="list1">
        <li v-for="(item1,index1) in arr1" :key='index1' 
        @click="handleClick1(index1);mysort(index1)" :class='{active1:currentIndex1==index1}'
       
        >{{item1}}</li>
     
    </ul>
     <ul class="list2" >
        <li v-for="(item,index) in arr2" :key="index">{{item}}</li>
       
    </ul>

    <div class="list3" v-for="(item,index) in arr"  :key='index'>
        <div class="left">
            <img src="./1.img.jpg" alt="">
        </div>
        <div class="right">
             <h2>{{item.name}}</h2>
            <p><span>⭐️{{item.wjx}}</span>  &nbsp;<span>月售{{item.num}}</span></p> 
            <p>
                <span>起送￥{{item.price}}</span>&nbsp;
                <span>远距离配送￥{{item.psf}}</span>&nbsp;
                <span>{{item.min}}分钟</span> &nbsp;
                <span>{{item.juli}}km</span>
            </p>
        </div>
       
    </div>
   

  </div>
</template>

<script>
export default {
 data(){
    return{
        currentIndex1:0,
      arr:[
        {pic:'1.img.jpg',name:'金百万烤鸭(苏家坨店)',wjx:4.3,num:1632,price:20,
        psf:3,yuanjia:6,min:47,juli:3.9},
         {pic:'./1.img.jpg',name:'饺子馆',wjx:4.4,num:230,price:25,
        psf:3.5,yuanjia:4.5,min:44,juli:2.5},
         {pic:'./1.img.jpg',name:'炒面馆',wjx:4.4,num:560,price:80,
        psf:3.5,yuanjia:4.5,min:44,juli:2.9}
      ],
      arr1:['综合排序','距离最近','销量最高','筛选'],
      arr2:['年贷节热卖','津贴联盟','满减优惠','品质联盟']


    }
 },
 methods:{
    handleClick1(index1){
         this.currentIndex1=index1;
       
    },
    mysort(index1){
        if(index1==0){
              this.arr.sort((a,b)=>{
              return a.num-b.num;
         })
        }else if(index1==1){
            this.arr.sort((a,b)=>{
              return b.price-a.price;
            })
        }else if(index1==2){
             this.arr.sort((a,b)=>{
                return a.juli-b.juli
             })
        }else if(index1==3){
             this.arr.sort((a,b)=>{
                return b.min-a.min
             })
        }
    }
 }
}
</script>

<style>
 .list{
    margin: 10px;
 }
 .list1{
    display: flex;
    justify-content: space-around;
 }
 .list2{
    display: flex;
    justify-content: space-around;
    margin: 10px;
 }
 .list2 li{
    background-color:#b6b3b3;
    font-size: 14px;
 }
 .list3{
    margin: 10px;
    display: flex;
 }
  .list3 .left{
    width: 80px;
    height: 80px;
  }
 .list3 .left img{
    width: 70px;
    height: 70px;
    margin: 10px;
 }
   .list3 .right{
     width:100%;
     margin-left: 10px;
     margin-top: 10px;
  }
     .list3 .right p{
    font-size: 10px;

  }
  .active1{
    background-color: red;
  }

</style>